﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;

namespace SDB
{
    /// <summary>
    /// Interaction logic for UploadDisplay.xaml
    /// </summary>
    public partial class UploadDisplay : Window
    {
        public UploadDisplay()
        {
            InitializeComponent();
        }

        private void tvwFolders_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            TreeView curTreeview = (TreeView)sender;
            if (curTreeview.SelectedItem is DirectoryInfo)
            {
                try
                {
                    FileInfo[] files = ((DirectoryInfo)curTreeview.SelectedItem).GetFiles("*.mp3");
                    if (files.Length > 1)
                        lstLocalFiles.ItemsSource = files;
                }
                catch (UnauthorizedAccessException)
                {
                    string s = "(Access denied to this folder)";
                    lstLocalFiles.ItemsSource = new string[] { s };
                }
            }
            else if (curTreeview.SelectedItem is DriveInfo)
            {
                lstLocalFiles.ItemsSource = null;
            }
        }
    }
}
